package com.dl.mall.service.user.impl;

import com.dl.mall.mapper.BrandMapper;
import com.dl.mall.entity.Brand;
import com.dl.mall.service.user.BrandService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author DL
 * @create 2022-03-22 15:08
 */
@Service
@Transactional
public class BrandServiceImpl implements BrandService {

    @Resource
    BrandMapper brandMapper;

    /**
     * 根据 分区名 查询品牌
     * @param categoryId 分区id
     * @return 品牌
     */
    @Override
    public List<Brand> getBrandByCategoryId(Integer categoryId) {
        return brandMapper.queryBrandByCategoryId(categoryId);
    }

    /**
     * 根据 分区名 查询品牌
     * @param categoryName 分区名
     * @return 品牌
     */
    @Override
    public List<Brand> getBrandByCategoryId(String categoryName) {
        int type = 0;
        switch (categoryName){
            case "phone" : type = 1;break;
            case "computer" : type = 2;break;
            case "intelligent" : type = 3;break;
            case "accessory" : type = 4;break;
        }
        return brandMapper.queryBrandByCategoryId(type);
    }
}
